<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">业主姓名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="业主姓名不能为空"
                       placeholder="请输入业主姓名" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">业主电话</label>
            <div class="layui-input-block">
                <input type="text" name="tel" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="男" title="男" checked="">
                <input type="radio" name="sex" value="女" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">身份证号</label>
            <div class="layui-input-block">
                <input type="text" name="identity" lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">房子编号</label>
            <div class="layui-input-block">
                <input type="text" name="house_id" lay-verify="required" class="layui-input">
                <!--<select name="houseId" lay-verify="required"  id="typeId" lay-search="">
                    <option value="">请选择房子</option>
                </select>-->
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">住址</label>
            <div class="layui-input-block">
                <input type="text" name="address" lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script src="../../../static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            laydate=layui.laydate,
            $ = layui.$;

        // 日期
        // laydate.render({
        //     elem: '#date',
        //     trigger:'click'
        // });
        form.render();
        //查询所有的楼宇信息并渲染到select中
        /* $.get("house/queryAll",{},function (data) {
             var list=data;
             var select =document.getElementById("typeId");
             if(list!=null || list.size()>0){
                 for(var c in list){
                     var option=document.createElement("option");
                     option.setAttribute("value",list[c].id);
                     option.innerText=list[c].numbers;
                     select.appendChild(option);
                 }
             }
             form.render('select');
         },"json");*/



        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交

        form.on('submit(saveBtn)', function (data) {

            let  user  = JSON.stringify(data.field);
            $.post('/user?method=addUser',{user},function (res) {

                if(res.code==200){
                    layer.msg('执行成功',{
                        iocn:6,
                        time:500
                    },function () {
                        //重载父窗口 关闭当前窗口
                        parent.window.location.reload();
                        var iframeIndex=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    })

                }else{
                    layer.msg(res.msg,{icon:2})
                }

            },'JSON')



            return false;
        });

    });
</script>
</body>
</html>